package com.example.customcow;




import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.widget.Toast;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;


import android.content.Intent;
import android.os.Bundle;



public class Sistema_Ganadero extends SherlockFragmentActivity {

	// Declare Variables
	ActionBar mActionBar;
	ViewPager mPager;
	Tab tab;
	String Nombre="";
	private String NombreDev="";
DetalleActivity ObjetoDetalle=new DetalleActivity();

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// Get the view from activity_main.xml
		setContentView(R.layout.activity_presentacion);
	    
		
	        
		// Activate Navigation Mode Tabs
		mActionBar = getSupportActionBar();
		
		mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
		mActionBar.setDisplayShowTitleEnabled(true);
		// Locate ViewPager in activity_main.xml
		mPager = (ViewPager) findViewById(R.id.pager);
		
		// Activate Fragment Manager
		FragmentManager fm = getSupportFragmentManager();

		// Capture ViewPager page swipes
		ViewPager.SimpleOnPageChangeListener ViewPagerListener = new ViewPager.SimpleOnPageChangeListener() {
			@Override
			public void onPageSelected(int position) {
				super.onPageSelected(position);
				// Find the ViewPager Position
				mActionBar.setSelectedNavigationItem(position);
			}
		};

		mPager.setOnPageChangeListener(ViewPagerListener);
		// Locate the adapter class called ViewPagerAdapter.java
		ViewPagerAdapter viewpageradapter = new ViewPagerAdapter(fm);
		// Set the View Pager Adapter into ViewPager
		mPager.setAdapter(viewpageradapter);
		
		// Capture tab button clicks
		ActionBar.TabListener tabListener = new ActionBar.TabListener() {

			public void onTabSelected(Tab tab, FragmentTransaction ft) {
				// Pass the position on tab click to ViewPager
				mPager.setCurrentItem(tab.getPosition());
			}

			public void onTabUnselected(Tab tab, FragmentTransaction ft) {
				// TODO Auto-generated method stub
			}

			public void onTabReselected(Tab tab, FragmentTransaction ft) {
				// TODO Auto-generated method stub
			}
		};

		// Create first Tab
		tab = mActionBar.newTab().setText("Ventas").setTabListener(tabListener);
		mActionBar.addTab(tab);
		
		// Create second Tab
		tab = mActionBar.newTab().setText("Compras").setTabListener(tabListener);
		mActionBar.addTab(tab);
		
		// Create third Tab
		tab = mActionBar.newTab().setText("Consultas").setTabListener(tabListener);
		mActionBar.addTab(tab);

	}
	
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		MenuInflater Inflater= getSupportMenuInflater();
		  Inflater.inflate(R.menu.activity_presentacion, menu);
		return true;
	}

	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
	        case R.id.menu_new:
	            Log.i("ActionBar", "Nuevo!");
	            
	            Toast.makeText(getApplicationContext(), "Open Menu", Toast.LENGTH_LONG).show();
	            return true;
	        case R.id.menu_save:
	            Log.i("ActionBar", "Guardar!");;
	          Toast.makeText(getApplicationContext(), "Este es mi Nombre"+NombreDev,Toast.LENGTH_LONG).show();
	            
	            
	            Toast.makeText(getApplicationContext(), "Registro Guardado", Toast.LENGTH_LONG).show();
	            return true;
	        
	            
	            
	        default:
	            return super.onOptionsItemSelected(item);
		}
	}
	
	
	public String DevNombre( )
	{
				
	return this.NombreDev;
	}
	
	
	public void SetNombre( String Nombre)
	{
				
	NombreDev=Nombre;
	}
	
	
}
	
	
	


